home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 327 < prev    next >
Internet Message Format  |  1996-08-06  |  3KB

  1. Path: lyra.csx.cam.ac.uk!nmm1
  2. From: nmm1@cus.cam.ac.uk (Nick Maclaren)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Binary Mode stdin/stdout
  5. Date: 8 Feb 1996 10:26:55 GMT
  6. Organization: University of Cambridge, England
  7. Message-ID: <4fcj5f$2ft@lyra.csx.cam.ac.uk>
  8. References: <4f67kg$11g@cortex.dialin.rrze.uni-erlangen.de> <DME74w.4M4@stdc.demon.co.uk> <4fbnr3$veg@usenet.pa.dec.com>
  9. NNTP-Posting-Host: ursa.cus.cam.ac.uk
  10.  
  11. In article <4fbk81$qk@cortex.dialin.rrze.uni-erlangen.de>, mskuhn@unrza3.dialin.rrze.uni-erlangen.de (Markus Kuhn) writes:
  12. |> clive@stdc.demon.co.uk (Clive D.W. Feather) writes:
  13. |> 
  14. |> >In article <4f67kg$11g@cortex.dialin.rrze.uni-erlangen.de>,
  15. |> >Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de> wrote:
  16. |> >> Why isn't there a standard way of allowing an ISO C program to switch
  17. |> >> the standard input and output into binary transparent mode (as with
  18. |> >> the "b" flag in fopen()/freopen() for normal files)?
  19. |> >>
  20. |> >> Has this just been forgotten or is there a good technical reason?
  21. |> 
  22. |> >On some implementations, this decision has to be made at the time you
  23. |> >open the file and can't be changed.
  24. |> 
  25. |> I would already be happy with a portable function that allows to
  26. |> switch stdin or stdout to binary mode and that has only a well-defined
  27. |> behaviour according to the standard if this switch occurs before any
  28. |> byte has been written to or read from the stream. This would cause no
  29. |> headaches on your computing fossil (because inserting a newline during
  30. |> a later switch would not be non-conforming) and would be sufficient
  31. |> for all important applications I can think of (like zcat).
  32.  
  33. In article <4fbnr3$veg@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
  34. |> 
  35. |> I'll take your word for it.  I suppose the operating system would require
  36. |> the program to close the file and reopen it, so that is what the C standard
  37. |> requires the C program to do.  (This is also why the C standard requires C
  38. |> programs to simulate long int arithmetic on their own instead of building
  39. |> it into the language, since some hardware doesn't have it, right?)
  40.  
  41. Sorry, but these wouldn't work even on UNIX.  Not all 'files' can
  42. be closed and reopened - think of rewinding tapes, for example!
  43.  
  44. Even on MVS, it would be possible to have a run-time flag that
  45. selected between binary and text for stdin and stdout, but this
  46. would have nothing to do with the C standard.  When I wrote my
  47. interface, I never provided this because I regarded it as being
  48. more confusion than it was worth - remember that C binary I/O
  49. does not map well onto MVS sequential files.
  50.  
  51.  
  52. Nick Maclaren,
  53. University of Cambridge Computer Laboratory,
  54. New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
  55. Email:  nmm1@cam.ac.uk
  56. Tel.:  +44 1223 334761    Fax:  +44 1223 334679
  57.